Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix unknowns not present in initialization system in linearization #2809

Conversation

AayushSabharwal
Copy link
Member

Checklist

  • Appropriate tests were added
  • Any code changes were done in a way that does not break public API
  • All documentation related to code changes were updated
  • The new code follows the
    contributor guidelines, in particular the SciML Style Guide and
    COLPRAC.
  • Any new documentation only uses public API

Additional context

Add any other context about the problem here.

@AayushSabharwal AayushSabharwal force-pushed the as/linearization-initsys-missing-vars branch from f97dae6 to 1754cc9 Compare June 18, 2024 06:30
@ChrisRackauckas
Copy link
Member

Test the case I described, x => 2, x ~ y, and y => 2, x ~ y.

@AayushSabharwal
Copy link
Member Author

AayushSabharwal commented Jun 18, 2024

Does this test work? It passed locally, just making sure it's what you're looking for

@ChrisRackauckas
Copy link
Member

No it needs to be structurally simplified.

@@ -2002,7 +2002,9 @@ function linearization_function(sys::AbstractSystem, inputs,
p = todict(p)
newps = deepcopy(sys_ps)
for (k, v) in p
setp(sys, k)(newps, v)
if is_parameter(sys, p)
Copy link
Contributor

@baggepinnen baggepinnen Jun 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if there is something for which !is_parameter(sys, p)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a bug, thanks 😅

Copy link
Contributor

@baggepinnen baggepinnen Jun 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, you fixed something other than I had in mind actually, let me rephrase the question after the fix

what happens if there is something for which !is_parameter(sys, k)?

note p -> k

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. Well that piece of code handles parameters specified as a Dict. Its sole purpose is to update the MTKParameters object. If k is not a parameter, it's not in the parameter object, so it's ignored. If it's an unknown, it's already taken care of in u.

@AayushSabharwal
Copy link
Member Author

No it needs to be structurally simplified.

structural_simplify happens inside linearization_function, in io_preprocessing.

@AayushSabharwal AayushSabharwal force-pushed the as/linearization-initsys-missing-vars branch 2 times, most recently from c835625 to 7442618 Compare July 1, 2024 15:19
@AayushSabharwal AayushSabharwal force-pushed the as/linearization-initsys-missing-vars branch from 7442618 to 3e81ea4 Compare July 2, 2024 07:44
@ChrisRackauckas ChrisRackauckas merged commit f3b040d into SciML:master Jul 2, 2024
21 of 22 checks passed
@AayushSabharwal AayushSabharwal deleted the as/linearization-initsys-missing-vars branch July 2, 2024 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants